<?php
 @header("Content-Type:text/html;charset=utf-8");

 @include_once("conn.php");

 if(!isset($_GET['user'])){
      $obj =array();
      $obj["status"] = false;
      $obj["msg"] = "请传入完整参数";
      $json = json_encode($obj);
      exit($json);
 }

 $user =$_GET["user"];

 $sql = "select s.id,g.goodsId,g.goodsName,g.goodsImg,g.goodsPrice,s.isChecked,s.buynum from `shoppingchar` as s,`goodslist_copy`  as g where s.gid = g.goodsId and user = '$user'";

 $result = mysqli_query($conn,$sql);

 $obj = array();
 if($result){
     $list = array();
     // 解析数据  => 赋值给变量 $item  =>  有数据,循环解析  没有数据(null) =>跳出循环
     while($item = mysqli_fetch_assoc($result)){
        $item["subtotal"] = round($item["goodsPrice"] * $item["buynum"],2);
        $item["isChecked"] = $item["isChecked"]*1;
        array_push($list,$item);
     }
     $obj["status"] = true;
     $obj["msg"] = "OK";
     $obj["list"] = $list;
    
 }else{
    $obj["status"]=false;
    $obj["msg"] = "sql语句有误";
    $obj["sql"] = $sql;
 }
 echo json_encode($obj);
?>